package vivek.project.pocketmoney.common.interfaces
{
	import vivek.project.pocketmoney.common.utils.DateUtils;

	public class RecurssionInterface
	{

		public static function getNextExecutionDate(fromDate:Date, toDate:Date, onDate:int):Date
		{
			var currentDate:Date=new Date();
			if (DateUtils.dateCompare(fromDate, currentDate) == 1)
				fromDate=currentDate;
			var gc:Date=new Date(fromDate.getTime());
			gc.setDate(onDate);
			if ((DateUtils.dateCompare(gc, toDate) == 1) && DateUtils.dateCompare(gc, currentDate) == -1)
			{
				return gc;
			}
			else
			{
				while ((DateUtils.dateCompare(gc, toDate) == 1) && DateUtils.dateCompare(gc, currentDate) == 1)
				{
					gc=DateUtils.dateAdd("month", 1, gc);
				}
				return gc;
			}
		}
	}
}